#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
	int buffer, subtotal = 0, total = 0;
	bool is_last_input_zero = false;
	while(1)
	{
		cout << "Please enter an integer: ";
		cin >> buffer;
		subtotal += buffer;
		total += buffer;
		if(buffer == 0)
		{
			if (is_last_input_zero == true)
			{
				cout << "Total = " << total << endl;
				break;
			} 
			cout << "Subtotal = " << subtotal << endl;
			is_last_input_zero = true;
			subtotal = 0;
		}
		else
			is_last_input_zero = false;
	}
	return 0;
}
